﻿@page "/Bas/Customer/Details"
@using nERP.ViewModel.Bas.CustomerVMs
@using System.ComponentModel.DataAnnotations
@inherits BasePage

<div>
    <ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
        <Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
            <Display @bind-Value="@Model.Entity.CustomerCode" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.CustomerName" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.ContactPerson" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.PhoneNumber" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.Email" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.Faxing" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.BeginCollect" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.EndCollect" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.TaxtRate" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.Remark" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.Address" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.Bank" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.TaxpayerNumber" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.BankAccount" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.LandlinePhone" ShowLabel="true" IsDisabled="true" />
            <WTUploadImage @bind-Value="@Model.Entity.CustomerFile" IsDisabled="true" thumb-width="128" />
            <Display @bind-Value="@Model.Entity.CreateTime" ShowLabel="true" IsDisabled="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.UpdateTime" ShowLabel="true" IsDisabled="true" FormatString="yyyy-MM-dd HH:mm:ss" />
            <Display @bind-Value="@Model.Entity.CreateBy" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.UpdateBy" ShowLabel="true" IsDisabled="true" />
            <Display @bind-Value="@Model.Entity.IsValid" ShowLabel="true" IsDisabled="true" />
        </Row>

        <div class="modal-footer table-modal-footer">
            <Button OnClick="OnClose" Text="@WtmBlazor.Localizer["Sys.Close"]" />
        </div>

    </ValidateForm>

</div>



@code {
    [Parameter]
    public string id { get; set; }
    [Parameter]
    public string[] ids { get; set; }
    private CustomerVM Model = new CustomerVM();
    private ValidateForm vform { get; set; }
    private async Task Submit(EditContext context)
    {


        await PostsForm(vform, "/api/Bas/Customer/Edit", (s) => "Sys.OprationSuccess");
    }
    public void OnClose()
    {
        CloseDialog();
    }

    protected override async Task OnInitializedAsync()
    {


        if (id != "")
        {
            var rv = await WtmBlazor.Api.CallAPI<CustomerVM>($"/api/Bas/Customer/{id}");
            Model = rv.Data;
        }

        await base.OnInitializedAsync();
    }
}
